#include<bits/stdc++.h>
struct node{
    int d,v,a;
} c[100005];
int p[100005];
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    cin>>T;
    while(T--){
        int n,m,L,V,sum=0;
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++){
            cin>>c[i].d>>c[i].v>>c[i].a;
            if(c[i].v>V) sum++;
        }
        for(int i=1;i<=m;i++){
            int x;
            cin>>x;
            p[x]=1;
        }
        cout<<sum<<" "<<(m>1?m-1:1)<<endl;
    }
    return 0;
}